package com.mlc.wx.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.mlc.common.utils.DateUtils;
import com.mlc.system.domain.SysUserRole;
import com.mlc.system.mapper.SysUserRoleMapper;
import com.mlc.system.service.ISysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mlc.wx.mapper.UserMapper;
import com.mlc.wx.domain.User;
import com.mlc.wx.service.IUserService;
import com.mlc.common.core.text.Convert;

import javax.management.relation.Role;

/**
 * 微信用户Service业务层处理
 *
 * @author ZFC
 * @date 2024-06-30
 */
@Service
public class UserServiceImpl implements IUserService {
    @Autowired
    private UserMapper userMapper;

    @Autowired
    private ISysRoleService sysRoleService;

    @Autowired
    private SysUserRoleMapper userRoleMapper;

    /**
     * 查询微信用户
     *
     * @param id 微信用户主键
     * @return 微信用户
     */
    @Override
    public User selectUserById(Long id) {
        return userMapper.selectUserById(id);
    }

    /**
     * 查询微信用户列表
     *
     * @param user 微信用户
     * @return 微信用户
     */
    @Override
    public List<User> selectUserList(User user) {
        return userMapper.selectUserList(user);
    }

    @Override
    public User selectUserByOpenId(String openId) {
        return userMapper.selectUserByOpenId(openId);
    }

    /**
     * 新增微信用户
     *
     * @param user 微信用户
     * @return 结果
     */
    @Override
    public int insertUser(User user) {
        user.setCreateTime(DateUtils.getNowDate());
        return userMapper.insertUser(user);
    }

    /**
     * 修改微信用户
     *
     * @param user 微信用户
     * @return 结果
     */
    @Override
    public int updateUser(User user) {
        user.setUpdateTime(DateUtils.getNowDate());
        return userMapper.updateUser(user);
    }


    /**
     * 删除微信用户信息
     *
     * @param id 微信用户主键
     * @return 结果
     */
    @Override
    public int updateUserById(Long id) {
        return userMapper.updateUserById(id);
    }
}
